//
// CTileSet.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.IStream;

public class CTileSet {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CTileSet(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CTileSet obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CTileSet(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CTileSet() {
    this(nel3dJNI.new_CTileSet(), true);
  }

  public void addTile128(SWIGTYPE_p_int indexInTileSet, CTileBank bank) {
    nel3dJNI.CTileSet_addTile128(swigCPtr, this, SWIGTYPE_p_int.getCPtr(indexInTileSet), CTileBank.getCPtr(bank), bank);
  }

  public void addTile256(SWIGTYPE_p_int indexInTileSet, CTileBank bank) {
    nel3dJNI.CTileSet_addTile256(swigCPtr, this, SWIGTYPE_p_int.getCPtr(indexInTileSet), CTileBank.getCPtr(bank), bank);
  }

  public void removeTile128(int indexInTileSet, CTileBank bank) {
    nel3dJNI.CTileSet_removeTile128(swigCPtr, this, indexInTileSet, CTileBank.getCPtr(bank), bank);
  }

  public void removeTile256(int indexInTileSet, CTileBank bank) {
    nel3dJNI.CTileSet_removeTile256(swigCPtr, this, indexInTileSet, CTileBank.getCPtr(bank), bank);
  }

  public void clearTile128(int indexInTileSet, CTile.TBitmap type, CTileBank bank) {
    nel3dJNI.CTileSet_clearTile128(swigCPtr, this, indexInTileSet, type.swigValue(), CTileBank.getCPtr(bank), bank);
  }

  public void clearTile256(int indexInTileSet, CTile.TBitmap type, CTileBank bank) {
    nel3dJNI.CTileSet_clearTile256(swigCPtr, this, indexInTileSet, type.swigValue(), CTileBank.getCPtr(bank), bank);
  }

  public void clearTransition(CTileSet.TTransition transition, CTile.TBitmap type, CTileBank bank) {
    nel3dJNI.CTileSet_clearTransition(swigCPtr, this, transition.swigValue(), type.swigValue(), CTileBank.getCPtr(bank), bank);
  }

  public void clearDisplacement(CTileSet.TDisplacement displacement, CTileBank bank) {
    nel3dJNI.CTileSet_clearDisplacement(swigCPtr, this, displacement.swigValue(), CTileBank.getCPtr(bank), bank);
  }

  public void setName(String name) {
    nel3dJNI.CTileSet_setName(swigCPtr, this, name);
  }

  public void setOriented(boolean oriented) {
    nel3dJNI.CTileSet_setOriented(swigCPtr, this, oriented);
  }

  public void setTile128(int indexInTileSet, String name, CTile.TBitmap type, CTileBank bank) {
    nel3dJNI.CTileSet_setTile128(swigCPtr, this, indexInTileSet, name, type.swigValue(), CTileBank.getCPtr(bank), bank);
  }

  public void setTile256(int indexInTileSet, String name, CTile.TBitmap type, CTileBank bank) {
    nel3dJNI.CTileSet_setTile256(swigCPtr, this, indexInTileSet, name, type.swigValue(), CTileBank.getCPtr(bank), bank);
  }

  public void setTileTransition(CTileSet.TTransition transition, String name, CTile.TBitmap type, CTileBank bank, CTileBorder border) {
    nel3dJNI.CTileSet_setTileTransition(swigCPtr, this, transition.swigValue(), name, type.swigValue(), CTileBank.getCPtr(bank), bank, CTileBorder.getCPtr(border), border);
  }

  public void setTileTransitionAlpha(CTileSet.TTransition transition, String name, CTileBank bank, CTileBorder border, short rotAlpha) {
    nel3dJNI.CTileSet_setTileTransitionAlpha(swigCPtr, this, transition.swigValue(), name, CTileBank.getCPtr(bank), bank, CTileBorder.getCPtr(border), border, rotAlpha);
  }

  public void setBorder(CTile.TBitmap type, CTileBorder border) {
    nel3dJNI.CTileSet_setBorder(swigCPtr, this, type.swigValue(), CTileBorder.getCPtr(border), border);
  }

  public void setDisplacement(CTileSet.TDisplacement displacement, String fileName, CTileBank bank) {
    nel3dJNI.CTileSet_setDisplacement(swigCPtr, this, displacement.swigValue(), fileName, CTileBank.getCPtr(bank), bank);
  }

  public void setTileVegetableDescFileName(String fileName) {
    nel3dJNI.CTileSet_setTileVegetableDescFileName(swigCPtr, this, fileName);
  }

  public void setTileVegetableDesc(CTileVegetableDesc tvd) {
    nel3dJNI.CTileSet_setTileVegetableDesc(swigCPtr, this, CTileVegetableDesc.getCPtr(tvd), tvd);
  }

  public void loadTileVegetableDesc() {
    nel3dJNI.CTileSet_loadTileVegetableDesc(swigCPtr, this);
  }

  public CTileSet.TError checkTile128(CTile.TBitmap type, CTileBorder border, SWIGTYPE_p_int pixel, SWIGTYPE_p_int composante) {
    return CTileSet.TError.swigToEnum(nel3dJNI.CTileSet_checkTile128(swigCPtr, this, type.swigValue(), CTileBorder.getCPtr(border), border, SWIGTYPE_p_int.getCPtr(pixel), SWIGTYPE_p_int.getCPtr(composante)));
  }

  public CTileSet.TError checkTile256(CTile.TBitmap type, CTileBorder border, SWIGTYPE_p_int pixel, SWIGTYPE_p_int composante) {
    return CTileSet.TError.swigToEnum(nel3dJNI.CTileSet_checkTile256(swigCPtr, this, type.swigValue(), CTileBorder.getCPtr(border), border, SWIGTYPE_p_int.getCPtr(pixel), SWIGTYPE_p_int.getCPtr(composante)));
  }

  public CTileSet.TError checkTileTransition(CTileSet.TTransition transition, CTile.TBitmap type, CTileBorder border, SWIGTYPE_p_int indexError, SWIGTYPE_p_int pixel, SWIGTYPE_p_int composante) {
    return CTileSet.TError.swigToEnum(nel3dJNI.CTileSet_checkTileTransition(swigCPtr, this, transition.swigValue(), type.swigValue(), CTileBorder.getCPtr(border), border, SWIGTYPE_p_int.getCPtr(indexError), SWIGTYPE_p_int.getCPtr(pixel), SWIGTYPE_p_int.getCPtr(composante)));
  }

  public String getName() {
    return nel3dJNI.CTileSet_getName(swigCPtr, this);
  }

  public boolean getOriented() {
    return nel3dJNI.CTileSet_getOriented(swigCPtr, this);
  }

  public int getNumTile128() {
    return nel3dJNI.CTileSet_getNumTile128(swigCPtr, this);
  }

  public int getNumTile256() {
    return nel3dJNI.CTileSet_getNumTile256(swigCPtr, this);
  }

  public int getTile128(int index) {
    return nel3dJNI.CTileSet_getTile128(swigCPtr, this, index);
  }

  public int getTile256(int index) {
    return nel3dJNI.CTileSet_getTile256(swigCPtr, this, index);
  }

  public CTileSetTransition getTransition(int index) {
    long cPtr = nel3dJNI.CTileSet_getTransition__SWIG_0(swigCPtr, this, index);
    return (cPtr == 0) ? null : new CTileSetTransition(cPtr, false);
  }

  public CTileBorder getBorder128(CTile.TBitmap bitmapType) {
    long cPtr = nel3dJNI.CTileSet_getBorder128(swigCPtr, this, bitmapType.swigValue());
    return (cPtr == 0) ? null : new CTileBorder(cPtr, false);
  }

  public CTileBorder getBorder256(CTile.TBitmap bitmapType) {
    long cPtr = nel3dJNI.CTileSet_getBorder256(swigCPtr, this, bitmapType.swigValue());
    return (cPtr == 0) ? null : new CTileBorder(cPtr, false);
  }

  public String getTileVegetableDescFileName() {
    return nel3dJNI.CTileSet_getTileVegetableDescFileName(swigCPtr, this);
  }

  public long getDisplacementTile(CTileSet.TDisplacement displacement) {
    return nel3dJNI.CTileSet_getDisplacementTile(swigCPtr, this, displacement.swigValue());
  }

  public CTileVegetableDesc getTileVegetableDesc() {
    return new CTileVegetableDesc(nel3dJNI.CTileSet_getTileVegetableDesc__SWIG_0(swigCPtr, this), false);
  }

  public static String getErrorMessage(CTileSet.TError error) {
    return nel3dJNI.CTileSet_getErrorMessage(error.swigValue());
  }

  public static CTileSet.TTransition getTransitionTile(CTileSet.TFlagBorder top, CTileSet.TFlagBorder bottom, CTileSet.TFlagBorder left, CTileSet.TFlagBorder right) {
    return CTileSet.TTransition.swigToEnum(nel3dJNI.CTileSet_getTransitionTile(top.swigValue(), bottom.swigValue(), left.swigValue(), right.swigValue()));
  }

  public CTileSet.TTransition getExistingTransitionTile(CTileSet.TFlagBorder _top, CTileSet.TFlagBorder _bottom, CTileSet.TFlagBorder _left, CTileSet.TFlagBorder _right, int reject, CTile.TBitmap type) {
    return CTileSet.TTransition.swigToEnum(nel3dJNI.CTileSet_getExistingTransitionTile(swigCPtr, this, _top.swigValue(), _bottom.swigValue(), _left.swigValue(), _right.swigValue(), reject, type.swigValue()));
  }

  public static CTileSet.TTransition getComplementaryTransition(CTileSet.TTransition transition) {
    return CTileSet.TTransition.swigToEnum(nel3dJNI.CTileSet_getComplementaryTransition(transition.swigValue()));
  }

  public static CTileSet.TFlagBorder getInvertBorder(CTileSet.TFlagBorder border) {
    return CTileSet.TFlagBorder.swigToEnum(nel3dJNI.CTileSet_getInvertBorder(border.swigValue()));
  }

  public static CTileSet.TFlagBorder getOrientedBorder(CTileSet.TBorder where, CTileSet.TFlagBorder border) {
    return CTileSet.TFlagBorder.swigToEnum(nel3dJNI.CTileSet_getOrientedBorder(where.swigValue(), border.swigValue()));
  }

  public static CTileSet.TFlagBorder getEdgeType(CTileSet.TTransition _what, CTileSet.TBorder _where) {
    return CTileSet.TFlagBorder.swigToEnum(nel3dJNI.CTileSet_getEdgeType(_what.swigValue(), _where.swigValue()));
  }

  public static CTileSet.TTransition rotateTransition(CTileSet.TTransition transition) {
    return CTileSet.TTransition.swigToEnum(nel3dJNI.CTileSet_rotateTransition(transition.swigValue()));
  }

  public void cleanUnusedData() {
    nel3dJNI.CTileSet_cleanUnusedData(swigCPtr, this);
  }

  public void addChild(String name) {
    nel3dJNI.CTileSet_addChild(swigCPtr, this, name);
  }

  public void removeChild(String name) {
    nel3dJNI.CTileSet_removeChild(swigCPtr, this, name);
  }

  public boolean isChild(String name) {
    return nel3dJNI.CTileSet_isChild(swigCPtr, this, name);
  }

  public void serial(IStream f) {
    nel3dJNI.CTileSet_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public void setSurfaceData(long value) {
    nel3dJNI.CTileSet_SurfaceData_set(swigCPtr, this, value);
  }

  public long getSurfaceData() {
    return nel3dJNI.CTileSet_SurfaceData_get(swigCPtr, this);
  }

  public final static class TError {
    public final static TError ok = new TError("ok", nel3dJNI.CTileSet_ok_get());
    public final static TError topInterfaceProblem = new TError("topInterfaceProblem");
    public final static TError bottomInterfaceProblem = new TError("bottomInterfaceProblem");
    public final static TError leftInterfaceProblem = new TError("leftInterfaceProblem");
    public final static TError rightInterfaceProblem = new TError("rightInterfaceProblem");
    public final static TError addFirstA128128 = new TError("addFirstA128128");
    public final static TError topBottomNotTheSame = new TError("topBottomNotTheSame");
    public final static TError rightLeftNotTheSame = new TError("rightLeftNotTheSame");
    public final static TError sizeInvalide = new TError("sizeInvalide");
    public final static TError errorCount = new TError("errorCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TError swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TError.class + " with value " + swigValue);
    }

    private TError(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TError(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TError(String swigName, TError swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TError[] swigValues = { ok, topInterfaceProblem, bottomInterfaceProblem, leftInterfaceProblem, rightInterfaceProblem, addFirstA128128, topBottomNotTheSame, rightLeftNotTheSame, sizeInvalide, errorCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TTransition {
    public final static TTransition first = new TTransition("first", nel3dJNI.CTileSet_first_get());
    public final static TTransition last = new TTransition("last", nel3dJNI.CTileSet_last_get());
    public final static TTransition count = new TTransition("count", nel3dJNI.CTileSet_count_get());
    public final static TTransition notfound = new TTransition("notfound", nel3dJNI.CTileSet_notfound_get());

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TTransition swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TTransition.class + " with value " + swigValue);
    }

    private TTransition(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TTransition(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TTransition(String swigName, TTransition swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TTransition[] swigValues = { first, last, count, notfound };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TDisplacement {
    public final static TDisplacement FirstDisplace = new TDisplacement("FirstDisplace", nel3dJNI.CTileSet_FirstDisplace_get());
    public final static TDisplacement LastDisplace = new TDisplacement("LastDisplace", nel3dJNI.CTileSet_LastDisplace_get());
    public final static TDisplacement CountDisplace = new TDisplacement("CountDisplace", nel3dJNI.CTileSet_CountDisplace_get());

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TDisplacement swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TDisplacement.class + " with value " + swigValue);
    }

    private TDisplacement(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TDisplacement(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TDisplacement(String swigName, TDisplacement swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TDisplacement[] swigValues = { FirstDisplace, LastDisplace, CountDisplace };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TBorder {
    public final static TBorder top = new TBorder("top", nel3dJNI.CTileSet_top_get());
    public final static TBorder bottom = new TBorder("bottom");
    public final static TBorder left = new TBorder("left");
    public final static TBorder right = new TBorder("right");
    public final static TBorder borderCount = new TBorder("borderCount");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TBorder swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TBorder.class + " with value " + swigValue);
    }

    private TBorder(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TBorder(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TBorder(String swigName, TBorder swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TBorder[] swigValues = { top, bottom, left, right, borderCount };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TFlagBorder {
    public final static TFlagBorder _1111 = new TFlagBorder("_1111", nel3dJNI.CTileSet__1111_get());
    public final static TFlagBorder _0111 = new TFlagBorder("_0111");
    public final static TFlagBorder _1110 = new TFlagBorder("_1110");
    public final static TFlagBorder _0001 = new TFlagBorder("_0001");
    public final static TFlagBorder _1000 = new TFlagBorder("_1000");
    public final static TFlagBorder _0000 = new TFlagBorder("_0000");
    public final static TFlagBorder dontcare = new TFlagBorder("dontcare", nel3dJNI.CTileSet_dontcare_get());

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TFlagBorder swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TFlagBorder.class + " with value " + swigValue);
    }

    private TFlagBorder(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TFlagBorder(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TFlagBorder(String swigName, TFlagBorder swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TFlagBorder[] swigValues = { _1111, _0111, _1110, _0001, _1000, _0000, dontcare };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
